//
//  SYStatus.swift
//  YANAWeibo
//
//  Created by mac on 16/5/15.
//  Copyright © 2016年 itcast. All rights reserved.
//

import UIKit
//微博数据模型
class SYStatus: NSObject {
    /// 发微博时间
    var created_at: String?
    /// 微博id
    var id: Int64 = 0
    /// 微博内容
    var text: String?
    /// 微博来源
    var source: String?
    /// 用户模型
    var user: SYUser?
    /// 转发微博模型
    var retweeted_status: SYStatus?
    
    ///  转发数
    var reposts_count: Int = 0
    ///  评论数
    var comments_count: Int = 0
    ///  表态数
    var attitudes_count: Int = 0
    
    /// 配图数据
    var pic_urls: [SYStatusPictureInfo]?

    
    init(dic: [String: AnyObject]) {
        super.init()
        setValuesForKeysWithDictionary(dic)
    }
    
    override func setValue(value: AnyObject?, forKey key: String) {
        if key == "user" {
            guard let dic = value as? [String: AnyObject] else {
                return
            }
            user = SYUser(dic: dic)
        }else if key == "retweeted_status" {
            guard let dic = value as? [String: AnyObject] else {
                return
            }
            retweeted_status = SYStatus(dic: dic)
        
        }else if key == "pic_urls" {
            guard let dicArray = value as? [[String: AnyObject]] else {
                return
            }
            var tempArray = [SYStatusPictureInfo]()
            for dic in dicArray {
                let picInfo = SYStatusPictureInfo(dic: dic)
                tempArray.append(picInfo)
            }
            pic_urls = tempArray
            
        }else{
            super.setValue(value, forKey: key)
        }
    }
    
    override func setValue(value: AnyObject?, forUndefinedKey key: String) {
    }
}
